<template>
  <div>
    <div class="title font14 ma30-15">
      <p>我参加的活动</p>
    </div>
    <div class="pa15 bor7 activity">
      <div>
        <!-- 内容 -->
        <div class="table-responsive">
          <table class="table">
            <tbody>
              <tr>
                <th>订单编号</th>
                <th>所属活动</th>
                <th>活动费用</th>
                <th>下单时间</th>
                <th>活动状态</th>
                <th>开始时间</th>
                <th>订单状态</th>
                <th>支付方式</th>
                <th>操作</th>
              </tr>
              <tr v-for="itemList in this.defaultList" :key="itemList.id">
                <td>{{ itemList.out_trade_no }}</td>
                <td>{{ itemList.title }}</td>
                <td>￥{{ itemList.origin_money }}</td>
                <td>{{ itemList.create_time | formatDate }}</td>
                <td>
                  <span v-if="itemList.activity_status == 1">已结束</span>
                  <span class="free" v-if="itemList.activity_status == 2"
                    >已取消</span
                  >
                  <el-button type="text" v-if="itemList.activity_status == 0"
                    >还未开始</el-button
                  >

	      </td>
              <td>{{ itemList.start_datetime | formatDate }}</td>
              <td v-if="itemList.status == 1">已支付</td>
              <td v-else>未支付</td>
              <td>{{ itemList.pay_method }}</td>
              <td>
                <el-button type="success" v-if="itemList.status = 0">去支付</el-button>
                  <router-link
                    :to="{
                      path: '/hotshow',
                      query: { id: itemList.product_id },
                    }"
                    target="_blank"
                    class="primary"
                    >活动详情</router-link
                  >
                  <router-link
                    :to="{ path: '/information#reloaded' }"
                    class="xiaoxi"
                    >消息</router-link
                  >
                </td>
              </tr>
            </tbody>
          </table>
        </div>
        <!-- 判断没有内容是显示 -->
        <!-- <el-empty description="您还未参加过任何活动">
        <el-button type="primary">去看看</el-button>
      </el-empty> -->
        <!-- 分页 -->
        <div class="block ta">
          <el-pagination
            layout="  prev, pager, next "
            :page-size="page_size"
            @current-change="current_change"
            :current-page.sync="currentPage"
            :pager-count="5"
            :total="info.total"
            v-if="info.pages > 1"
          >
          </el-pagination>

    <el-empty description="暂无数据" v-if="info.total == 0"></el-empty>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { formatDate } from "../../assets/data.js";
export default {
  // 时间戳
  filters: {
    formatDate(time) {
      time = time * 1000;
      let date = new Date(time);
      return formatDate(date, "yyyy-MM-dd hh:mm:ss");
    },
  },
  data() {
    return {
      isActive: 1,
      defaultList: [],
      info: [], //数据
      page_size: 8, //每页多少数据
      currentPage: 1, //默认当前页为第一页
      sort: "",
      keyword: "",
      visible1: false,
      visible2: false,
      visible3: false,
      visible4: false,
      visible5: false,
      visible6: false,
      visible7: false,
    };
  },
  mounted() {
    this.getAllList();
  },
  methods: {
    getAllList() {
      var that = this;
      this.$axios
        .get(
          this.$api +
            "//api/order/index?page_no=" +
            that.currentPage +
            "&page_size=" +
            that.page_size +
            "&sort=" +
            that.sort +
            "&order=desc"
        )
        .then(function (response) {
          that.defaultList = response.data.data.data;
          that.info = response.data.data.page;
          ////console.log(that.defaultList);
        })
        .catch(function (error) {
          //console.log(error);
        });
    },
    current_change(currentPage) {
      //改变当前页
      this.currentPage = currentPage;
      this.getAllList();
    },
    defaultSearch() {
      ////console.log(this.keyword);
      this.getAllList();
    },
  },
};
</script>

<style scoped>
.content-box .table {
  margin-bottom: 0;
}
html {
  height: 100% !important;
  overflow-y: hidden !important;
}
.activity > div {
  padding-bottom: 20px;
}
.activity>div:hover {
      border: solid 1px #dedede;
}
 th {
  border-top: none;
  background: #f6f5f5;
  font-size: 0.875rem;
  color: #545556;
  line-height: 3.4375rem !important;
  text-align: center;
  font-size: 0.875rem;
}
table tr td {
  line-height: 3.4375rem !important;
  text-align: center;
  font-size: 0.875rem;
}
.el-button--info {
  border-radius: 0.25rem;
  background: #f6f5f5;
  border: 1px solid #f6f5f5;
  color: #545556;
}
.el-button {
  padding: 0.3125rem 0.625rem;
  font-size: 0.875rem;
}
.table > tbody > tr > td {
  border-top: 1px solid #f6f5f5;
}
.el-button + .el-button {
  margin-left: 0.25rem;
}
.el-button--success {
  background: #19a15f;
}
.el-radio {
  margin-right: 0.5rem;
}
.el-radio__label {
  font-size: 0.875rem;
  padding-left: 0.3125rem;
}
tr .free {
  color: #de5044;
}
</style>
